package com.hs.mpdemo_01.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hs.mpdemo_01.entity.Teacher;
import com.hs.mpdemo_01.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

/**
 * @ClassName TeacherController
 * @Description TODO
 */
@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Autowired
    private TeacherService service;

    @GetMapping("/page/{pageNum}/{pageSize}")
    public HashMap<String,Object> findbyPage(@PathVariable Integer pageNum, @PathVariable Integer pageSize){
        Page<Teacher> page = service.findByPage(pageNum, pageSize);
        HashMap<String,Object> map = new HashMap<String,Object>();
        map.put("list",page.getRecords());
        map.put("total",page.getTotal());
        map.put("totalPages",page.getPages());
        return map;
    }
}
